package com.kunya.product.controller.portall;

import com.kunya.common.common.ServerResponse;
import com.kunya.product.po.Specification;
import com.kunya.product.service.specofocation.ISpecificationService;
import com.kunya.common.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 规格管理
 * @author suimg
 * @Description:
 * @date 2018/7/10 15:21
 */
@RestController
@RequestMapping("/specification")
public class SpecificationController {

    @Autowired
    private ISpecificationService iSpecificationService;

    /**
     * 创建新的规格名称
     * @param categoryId
     * @param name
     * @param status
     * @param sort
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value="/addnew_specification",method = RequestMethod.POST)
    public ServerResponse addnewSpecification(Long categoryId,String name, Byte status, Integer sort,HttpServletRequest httpServletRequest){
       return iSpecificationService.addnewSpecification(categoryId,name,status,sort,CommonUtil.getTablePiefix(httpServletRequest));
    }

    /**
     * 修改规格名称
     * @param specification
     * @return
     */
    @RequestMapping(value = "/updateSpecification")
    public ServerResponse updateSpecification(Specification specification){
        return iSpecificationService.updateSpecification(specification,"340_");
    }

    /**
     * 删除规格
     * @param specification
     * @return
     */
    @RequestMapping(value = "/deleteSpecification")
    public ServerResponse deleteSpecification(Specification specification){
        return iSpecificationService.deleteSpecification(specification,"340_");
    }

    /**
     * 查询分类规格名称列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/seleteSpecification")
    public ServerResponse seleteSpecification(Integer pageNum,Integer pageSize){
        return iSpecificationService.seleteSpecification(pageNum,pageSize,"340_");
    }

}
